﻿using DevExpress.XtraEditors.Controls;
using RecruitStudents.Client.BLL;
using RecruitStudents.Utility;
using RecruitStudents.Utility.Const;
using RecruitStudents.Utility.Helper;
using RecruitStudents.Utility.Model;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace RecruitStudents.Client.Base
{
    public partial class Base_ExamScoreTypeForm_Option : BaseForm
    {
        TB_Sys_ExamScoreType model = null;
        ServiceBase service = new ServiceBase();
        string strDataID = string.Empty;
        public Base_ExamScoreTypeForm_Option(string strdataid)
        {
            InitializeComponent();
            strDataID = strdataid;
            this.cmbPadScoreTpye.Properties.NullText = "";
            this.cmbPadScoreTpye.Properties.Columns.Add(new LookUpColumnInfo("Key", 30, "展现方式代码"));
            this.cmbPadScoreTpye.Properties.Columns.Add(new LookUpColumnInfo("Value", 55, "展现方式名称"));
            this.cmbPadScoreTpye.Properties.DataSource = ConstAppConfig.DicPadScoreType.ToList();
            this.cmbPadScoreTpye.Properties.DisplayMember = "Value";
            this.cmbPadScoreTpye.Properties.ValueMember = "Key";
            if (strDataID.Length > 0)
            {
                model = service.GetExamScoreTypeModel(strDataID);
                if (model != null)
                {
                    //txtNo.Enabled = false;
                    model.Attach();
                    //txtNo.Text = model.ExamScoreTypeNO;
                    txtName.Text = model.ExamScoreTypeName;
                    cmbPadScoreTpye.EditValue = model.PadScoreTpye;
                    if (model.IsPad == "1")
                    {
                        chkSFTY.Checked = true;
                    }
                    else
                    {
                        chkSFTY.Checked = false;
                    }
                    model.Attach();
                }
            }


        }

        private void simpleButton2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void simpleButton1_Click(object sender, EventArgs e)
        {
            //if (string.IsNullOrEmpty(txtNo.Text))
            //{
            //    DevHelper.ShowInfoMessageBox("请输入编码！");
            //    txtNo.Focus();
            //    return;
            //}
            if (string.IsNullOrEmpty(txtName.Text))
            {
                DevHelper.ShowInfoMessageBox("请输入名称！");
                txtName.Focus();
                return;
            }
            if (string.IsNullOrEmpty(cmbPadScoreTpye.Text))
            {
                DevHelper.ShowInfoMessageBox("请选择类型！");
                cmbPadScoreTpye.Focus();
                return;
            }
            if (model == null)
            {
                model = new TB_Sys_ExamScoreType();
            }
            //model.ExamScoreTypeNO = txtNo.Text;
            model.ExamScoreTypeName = txtName.Text;
            model.PadScoreTpye = cmbPadScoreTpye.EditValue.ToString();
            model.ExamYear = SessionerHelper.SystemYear;
            if (chkSFTY.Checked)
            {
                model.IsPad = "1";
            }
            else
            {
                model.IsPad = "0";
            }
            if (service.SaveExamScoreType(model))
            {
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
        }
    }
}
